import {CHANGE_TAB, GET_FILTER_DATA, CHANGE_FILTER} from './actionType.js'
import axios from 'axios'

export const changeTab = (obj) => (dispatch) => {
  dispatch({
    type: CHANGE_TAB,
    obj
  })
}

export const getFilterData = () => async (dispatch) => {
  // axios({
  //   url: '/json/filter.json',
  //   method: 'get'
  // }).then(res => {
  //   console.log(res.data)
  // })
  let res = await axios({
    url: './json/filter.json',
    method: 'get'
  })
  dispatch({
    type: GET_FILTER_DATA,
    obj: res.data
  })
}

export const changeFilter = (obj) => (dispatch) => {
  dispatch({
    type: CHANGE_FILTER,
    obj
  })
  dispatch({
    type: CHANGE_FILTER,
    obj: {
      closePanel: true
    }
  })
}